<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //代码加载时,会优先加载函数,然后才是其他代码
        fun();

        function fun() {
            console.log('我执行了');
        }
        //我执行了
        //undefined
    </script>
</body>

</html>